{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Ranged Dot Plot\n",
    "-----------------\n",
    "This example shows a ranged dot plot that uses 'layer' to convey changing life expectancy for the five most populous countries (between 1955 and 2000).\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "import altair as alt\n",
    "alt.data_transformers.enable('json')\n",
    "from vega_datasets import data\n",
    "\n",
    "\n",
    "chart = alt.layer(\n",
    "    data=data.countries.url\n",
    ").transform_filter(\n",
    "    filter={\"field\": 'country',\n",
    "            \"oneOf\": [\"China\", \"India\", \"United States\", \"Indonesia\", \"Brazil\"]}\n",
    ").transform_filter(\n",
    "    filter={'field': 'year',\n",
    "            \"oneOf\": [1955, 2000]}\n",
    ")\n",
    "\n",
    "chart += alt.Chart().mark_line(color='#db646f').encode(\n",
    "    x='life_expect:Q',\n",
    "    y='country:N',\n",
    "    detail='country:N'\n",
    ")\n",
    "# Add points for life expectancy in 1955 & 2000\n",
    "chart += alt.Chart().mark_point(\n",
    "    size=100,\n",
    "    opacity=1,\n",
    "    filled=True\n",
    ").encode(\n",
    "    x='life_expect:Q',\n",
    "    y='country:N',\n",
    "    color=alt.Color('year:O',\n",
    "        scale=alt.Scale(\n",
    "            domain=['1955', '2000'],\n",
    "            range=['#e6959c', '#911a24']\n",
    "        )\n",
    "    )\n",
    ").interactive()\n",
    "\n",
    "chart\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "env": {},
   "interrupt_mode": "signal",
   "language": "python",
   "metadata": {},
   "name": "python3"
  },
  "language": "python"
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
